(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

g(X) → u(h(X), h(X), X)
u(d, c(Y), X) → k(Y)
h(d) → c(a)
h(d) → c(b)
f(k(a), k(b), X) → f(X, X, X)

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

g(X) → u(h(X), h(X), X) [1]
u(d, c(Y), X) → k(Y) [1]
h(d) → c(a) [1]
h(d) → c(b) [1]
f(k(a), k(b), X) → f(X, X, X) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

g(X) → u(h(X), h(X), X) [1]
u(d, c(Y), X) → k(Y) [1]
h(d) → c(a) [1]
h(d) → c(b) [1]
f(k(a), k(b), X) → f(X, X, X) [1]

The TRS has the following type information:
g :: d:c → k
u :: d:c → d:c → d:c → k
h :: d:c → d:c
d :: d:c
c :: a:b → d:c
k :: a:b → k
a :: a:b
b :: a:b
f :: k → k → k → f

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

u(v0, v1, v2) → null_u [0]
h(v0) → null_h [0]
f(v0, v1, v2) → null_f [0]

And the following fresh constants:

null_u, null_h, null_f

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

g(X) → u(h(X), h(X), X) [1]
u(d, c(Y), X) → k(Y) [1]
h(d) → c(a) [1]
h(d) → c(b) [1]
f(k(a), k(b), X) → f(X, X, X) [1]
u(v0, v1, v2) → null_u [0]
h(v0) → null_h [0]
f(v0, v1, v2) → null_f [0]

The TRS has the following type information:
g :: d:c:null_h → k:null_u
u :: d:c:null_h → d:c:null_h → d:c:null_h → k:null_u
h :: d:c:null_h → d:c:null_h
d :: d:c:null_h
c :: a:b → d:c:null_h
k :: a:b → k:null_u
a :: a:b
b :: a:b
f :: k:null_u → k:null_u → k:null_u → null_f
null_u :: k:null_u
null_h :: d:c:null_h
null_f :: null_f

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

d => 0
a => 0
b => 1
null_u => 0
null_h => 0
null_f => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

f(z, z', z'') -{ 1 }→ f(X, X, X) :|: z' = 1 + 1, z = 1 + 0, z'' = X, X >= 0
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
g(z) -{ 1 }→ u(h(X), h(X), X) :|: X >= 0, z = X
h(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
h(z) -{ 1 }→ 1 + 1 :|: z = 0
h(z) -{ 1 }→ 1 + 0 :|: z = 0
u(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
u(z, z', z'') -{ 1 }→ 1 + Y :|: Y >= 0, z' = 1 + Y, z'' = X, X >= 0, z = 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[g(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[u(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[h(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[f(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(g(V, Out),1,[h(X1, Ret0),h(X1, Ret1),u(Ret0, Ret1, X1, Ret)],[Out = Ret,X1 >= 0,V = X1]).
eq(u(V, V1, V2, Out),1,[],[Out = 1 + Y1,Y1 >= 0,V1 = 1 + Y1,V2 = X2,X2 >= 0,V = 0]).
eq(h(V, Out),1,[],[Out = 1,V = 0]).
eq(h(V, Out),1,[],[Out = 2,V = 0]).
eq(f(V, V1, V2, Out),1,[f(X3, X3, X3, Ret2)],[Out = Ret2,V1 = 2,V = 1,V2 = X3,X3 >= 0]).
eq(u(V, V1, V2, Out),0,[],[Out = 0,V3 >= 0,V2 = V4,V5 >= 0,V = V3,V1 = V5,V4 >= 0]).
eq(h(V, Out),0,[],[Out = 0,V6 >= 0,V = V6]).
eq(f(V, V1, V2, Out),0,[],[Out = 0,V7 >= 0,V2 = V8,V9 >= 0,V = V7,V1 = V9,V8 >= 0]).
input_output_vars(g(V,Out),[V],[Out]).
input_output_vars(u(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(h(V,Out),[V],[Out]).
input_output_vars(f(V,V1,V2,Out),[V,V1,V2],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [f/4]
1. non_recursive : [h/2]
2. non_recursive : [u/4]
3. non_recursive : [g/2]
4. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into f/4
1. SCC is partially evaluated into h/2
2. SCC is partially evaluated into u/4
3. SCC is partially evaluated into g/2
4. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations f/4
* CE 13 is refined into CE [14]
* CE 12 is refined into CE [15]


### Cost equations --> "Loop" of f/4
* CEs [15] --> Loop 10
* CEs [14] --> Loop 11

### Ranking functions of CR f(V,V1,V2,Out)

#### Partial ranking functions of CR f(V,V1,V2,Out)


### Specialization of cost equations h/2
* CE 11 is refined into CE [16]
* CE 10 is refined into CE [17]
* CE 9 is refined into CE [18]


### Cost equations --> "Loop" of h/2
* CEs [16] --> Loop 12
* CEs [17] --> Loop 13
* CEs [18] --> Loop 14

### Ranking functions of CR h(V,Out)

#### Partial ranking functions of CR h(V,Out)


### Specialization of cost equations u/4
* CE 8 is refined into CE [19]
* CE 7 is refined into CE [20]


### Cost equations --> "Loop" of u/4
* CEs [19] --> Loop 15
* CEs [20] --> Loop 16

### Ranking functions of CR u(V,V1,V2,Out)

#### Partial ranking functions of CR u(V,V1,V2,Out)


### Specialization of cost equations g/2
* CE 6 is refined into CE [21,22,23,24,25,26,27,28,29,30,31]


### Cost equations --> "Loop" of g/2
* CEs [29] --> Loop 17
* CEs [27] --> Loop 18
* CEs [21,22,23,24,25,26,28,30,31] --> Loop 19

### Ranking functions of CR g(V,Out)

#### Partial ranking functions of CR g(V,Out)


### Specialization of cost equations start/3
* CE 2 is refined into CE [32,33,34]
* CE 3 is refined into CE [35,36]
* CE 4 is refined into CE [37,38,39]
* CE 5 is refined into CE [40]


### Cost equations --> "Loop" of start/3
* CEs [32,33,34,35,36,37,38,39,40] --> Loop 20

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of f(V,V1,V2,Out):
* Chain [11]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]

* Chain [10,11]: 1
with precondition: [V=1,V1=2,Out=0,V2>=0]


#### Cost of chains of h(V,Out):
* Chain [14]: 1
with precondition: [V=0,Out=1]

* Chain [13]: 1
with precondition: [V=0,Out=2]

* Chain [12]: 0
with precondition: [Out=0,V>=0]


#### Cost of chains of u(V,V1,V2,Out):
* Chain [16]: 1
with precondition: [V=0,V1=Out,V1>=1,V2>=0]

* Chain [15]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]


#### Cost of chains of g(V,Out):
* Chain [19]: 3
with precondition: [Out=0,V>=0]

* Chain [18]: 3
with precondition: [V=0,Out=1]

* Chain [17]: 3
with precondition: [V=0,Out=2]


#### Cost of chains of start(V,V1,V2):
* Chain [20]: 3
with precondition: [V>=0]


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [20] with precondition: [V>=0]
- Upper bound: 3
- Complexity: constant

### Maximum cost of start(V,V1,V2): 3
Asymptotic class: constant
* Total analysis performed in 134 ms.

(10) BOUNDS(1, 1)